<template>
  <div>
    <!--    <FormPanel ref="from" :list="formList"  @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" :labelWidth="190"></FormPanel>-->
    <FormPanel ref="from" :list="formList" :isSubmitBtn="false" :collapse="false" :labelWidth="190"></FormPanel>
    <Spin :spinning="exportLoading" tip="Loading...">
      <el-tabs v-model="activeName" @tab-click="handleClick" :before-leave="beforeHandle">
        <el-tab-pane label="计划明细" name="first">
          <!-- <FilterTable
          ref="table"
          height="auto"
          :columns="columns"
          :dataSource="tableList"
          :onSyncTableData="syncTableFun"
          :onRowSelectChange="selectChangeHandle"
          :onColumnsChange="(columns) => (this.columns = columns)"
        > -->
          <FilterTable ref="table" height="auto" :columns="columns" :dataSource="tableList" :isSelectColumn="false" :onColumnsChange="(columns) => (this.columns = columns)">
            <template slot="controls">
              <multiuse-button size="small" type="primary" :click="addHandle" v-if="this.rowData.planStatus == 24041001">新 建</multiuse-button>
              <!-- <multiuse-button size="small" type="primary" :click="deleteHandle">删 除</multiuse-button> -->
            </template>
          </FilterTable>
        </el-tab-pane>
        <el-tab-pane label="计划汇总" name="second">
          <FilterTable ref="tableInfo" height="auto" :columns="columns1" :isSelectColumn="false" :dataSource="tableList1" :onColumnsChange="(columns1) => (this.columns1 = columns1)"> </FilterTable>
        </el-tab-pane>
      </el-tabs>
    </Spin>
    <BaseDialog :visible.sync="isShow" title="选择车辆" :width="'70%'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <addCar :rowData="rowData" @close="closeHandler" />
    </BaseDialog>
    <BaseDialog :visible.sync="isClient" :title="'订购方式'" destroyOnClose :width="'30%'" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <div>
        <FormPanel ref="fromUpdate" :list="formList1" :cols="2" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
        <div style="height: 47px"></div>
        <div
          :style="{
            position: 'absolute',
            left: 0,
            bottom: 0,
            right: 0,
            zIndex: 9,
            borderTop: '1px solid #e9e9e9',
            padding: '10px 20px',
            background: '#fff',
            textAlign: 'right',
          }"
        >
          <el-button @click="closeDrawer1(1)">关 闭</el-button>
          <multiuse-button type="primary" @click="closeDrawer1(2)">确 认</multiuse-button>
        </div>
      </div>
    </BaseDialog>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right',
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <multiuse-button type="primary" :click="closeDrawer.bind(this, 2)">导出明细</multiuse-button>
      <!--<multiuse-button type="primary" :click="closeDrawer.bind(this, 3)">保 存</multiuse-button> -->
      <multiuse-button :click="saveByIdsFun" type="primary" v-if="this.rowData.planStatus == 24041001">保 存</multiuse-button>
      <multiuse-button :click="saveByIdsFun" type="primary" v-if="this.rowData.planStatus == 24041002 || this.rowData.planStatus == 24041003">确 认</multiuse-button>
    </div>
  </div>
</template>
<script>
import moment from 'moment';
import { queryAllPlanDetail, updateReport, exportExcelDetail, listRecord, queryTargetType, queryTotalUrgency } from '@/api/dealerSale/salesPlan/MonthPlanReport';
import { dictionary } from '@/utils/dictMixin';
import addCar from './addCar';
import { exportExcelFile } from '@/utils';
export default {
  props: ['rowData', 'isAddPlan'],
  mixins: [dictionary],
  data() {
    return {
      formList: this.createdFrom(),
      formList1: this.createdFrom1(),
      columns: this.createdTable(),
      tableList: [],
      columns1: this.createdTable1(),
      tableList1: [],
      deleteData: [],
      isShow: false,
      isDisabled: true,
      activeName: 'first',
      isClient: false,
      dividData: null,
      unlock: false,
      exportLoading: false,
      adjustRate: null,
      urgencyRate: null,
      wuliaoList: [],
      planAllunJinJi: 0,
    };
  },
  components: {
    addCar,
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
    this.table = this.$refs.tableInfo.$refs.pageTable;
  },
  created() {
    // this.getPlanInfo();
    this.init();
    this.getListRecord();
  },
  methods: {
    //初始化数据
    async init() {
      //给FromPanl赋值
      if (this.rowData.planStatus === 24041001) this.unlock = true;
      for (let i in this.rowData) {
        this.formList.map((x) => {
          if (x.fieldName == i) {
            x.initialValue = this.rowData[i];
          }
        });
      }
      //给表格赋值
      const res = await queryAllPlanDetail({ id: this.rowData.id });
      if (res.resultCode === 200) {
        let data = res.data;
        let addressList = data[0].addressDTOS;
        data.forEach((element) => {
          if (element.urgency === 21011003) {
            this.$set(element, `${'adjustNum'}Disabled`, Boolean(true));
          }else{
            this.planAllunJinJi +=element.planNum;
          }
          addressList.forEach((e) => {
            if (e.addressId === element.addressId) {
              element.cityName = e.cityName;
              element.linkMan = e.linkMan;
              element.linkPhone = e.linkPhone;
            }
          });
        });
        this.tableList = data;
      }
      let arr = this.checkTargetNum();
      for (let b in arr) {
        if (arr[b].targetType === 24031002) {
          this.wuliaoList.push({ productCode: arr[b].productCode, beforeNum: arr[b].subtotal });
        }
      }
    },
    //获取业务基础参数
    async getListRecord() {
      const res = await listRecord();
      if (res.resultCode === 200) {
        for (let i in res.data) {
          if (res.data[i].paraCode === '40001001') {
            this.adjustRate = Number(res.data[i].paraValue);
          } else if (res.data[i].paraCode === '40001002') {
            this.urgencyRate = Number(res.data[i].paraValue);
          }
        }
      }
    },
    async editHandle(data, type) {
      if (type == 1) {
        await this.$confirm('是否确定删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(async () => {
            this.BaseTable.EXECUTE_DELETE([data]);
          })
          .catch(() => {});
      } else if (type === 2) {
        // this.BaseTable.EXECUTE_INSERT([data]);
        if (data.planNum === '') {
          this.$notify({
            title: '警告',
            message: '未填提报数量',
            type: 'warning',
          });
          return false;
        }
        this.isClient = true;
        // await this.$refs.fromUpdate.RESET_FORM();
        this.dividData = data;
      }
    },
    beforeHandle() {
      for (let i in this.tableList) {
        if (this.tableList[i].planNum === '') {
          this.activeName = 'first';
          this.$notify({
            title: '警告',
            message: '未填提报数量',
            type: 'warning',
          });
          this.tableList1 = [];
          return false;
        }
      }
    },
    handleClick(tab, event) {
      let a = this.tableList;
      if (tab.index === '0') {
        this.tableList1 = [];
      } else if (tab.index === '1') {
        let arr = this.checkTargetNum();
        this.table.EXECUTE_INSERT(arr);
      }
    },
    changeNum(index, data) {
      console.log(index, data, '改变数量');
      if (data.urgency === 21011003) {
        data.adjustNum = '';
        this.$notify({
          title: '警告',
          message: '紧急不允许调整数量',
          type: 'warning',
        });
        return;
      }
      let num = '';
      let str = '';
      for (let i in index) {
        num = index[i];
        str = i.split('|')[0];
      }
      if (num === '-' || num === '') {
        return;
      }
      let Rep = /^(-)?[1-9][0-9]*$/;
      if (!Rep.test(num)) {
        this.$notify({
          title: '警告',
          message: '输入应为整数',
          type: 'warning',
        });
        return;
      }
      if (num > 10000000000) {
        this.$notify({
          title: '警告',
          message: '输入数量过大',
          type: 'warning',
        });
        return;
      }
      if (Rep.test(num)) {
        let arr = this.tableList;
        let pre = 0;
        let add = 0;
        for (let i in this.tableList) {
          if (arr[i].productCode === data.productCode) {
            pre += Number(arr[i].planNum);
            if (arr[i].adjustNum !== null && arr[i].adjustNum !== '') {
              add += Number(arr[i].adjustNum);
            }
          }
        }
        let precent = this.adjustRate;
        if (Math.abs(Number(add)) <= Math.floor(pre * precent)) {
          if (data.planNum <= 0) {
            this.$notify({
              title: '警告',
              message: '修改后数量必须大于0',
              type: 'warning',
            });
            return false;
          }
        } else {
          // this.$notify({
          //   title: '警告',
          //   message: '修改数量有误',
          //   type: 'warning',
          // });
          // return false;
        }
      }
    },

    addHandle() {
      this.isShow = true;
    },
    closeHandler(type, data) {
      this.isShow = type;
      this.isDisabled = false;
      this.BaseTable.EXECUTE_INSERT(data);
    },
    async closeDrawer(type) {
      if (type === 1) {
        this.$emit('close', false);
      } else if (type === 2) {
        //导出
        await this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
          confirmButtonText: '下载',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            this.exportLoading = true;
            exportExcelDetail({ id: this.rowData.id })
              .then((response) => {
                exportExcelFile(response.data, 'C端月度计划明细');
                this.exportLoading = false;
              })
              .catch((err) => {
                console.log(err);
              });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消',
            });
          });
      }
    },
    async closeDrawer1(type) {
      if (type === 1) {
        this.$emit('close', false);
        this.dividData = null;
      } else if (type === 2) {
        let json = this.$refs.fromUpdate.SUBMIT_FORM();
        // var copy1 = JSON.parse(JSON.stringify(this.dividData));
        var copy2 = JSON.parse(JSON.stringify(this.dividData));
        if (Number(this.dividData.planNum + Number(this.dividData.adjustNum)) - Number(json.planNum) > 0 && Number(this.dividData.planNum) - Number(json.planNum) > 0) {
          this.dividData.planNum = Number(this.dividData.planNum) - Number(json.planNum);
          copy2.planNum = Number(json.planNum);
          copy2.adjustNum = '';
          copy2.demandPlan1DetailId = null;
          this.BaseTable.EXECUTE_INSERT([copy2]);
          this.$refs.fromUpdate.RESET_FORM();
          this.isClient = false;
          this.$notify({
            title: '成功',
            message: '拆分成功',
            type: 'success',
          });
          return;
        } else {
          this.$notify({
            title: '警告',
            message: '拆分后原始数量需要大于0',
            type: 'warning',
          });
        }
      }
    },
    async saveByIdsFun() {
      if (this.tableList.length < 1) {
        this.$notify({
          title: '警告',
          message: '至少添加一行数据',
          type: 'warning',
        });
        return false;
      }
      if (this.BaseTable.GET_REQUIRED_ERROR() != null) {
        for (let i in this.tableList) {
          if (this.tableList[i].accountId === '') {
            this.$notify.warning({ title: '提示信息', message: '资金类型不可为空！' });
            break;
          }
          if (this.tableList[i].addressId === '') {
            this.$notify.warning({ title: '提示信息', message: '收车地址不可为空！' });
            break;
          }
        }
        return false;
      }
      for (let i in this.tableList) {
        if (this.tableList[i].planNum <= 0) {
          this.$notify.warning({ title: '提示信息', message: '提报数量必须大于0！' });
          return false;
        }
      }
      for (let i in this.tableList) {
        if (i === 'dataMark' || this.tableList[i].adjustNum == '') {
          continue;
        } else {
          let num = this.tableList[i].adjustNum;
          let Rep = /^(-)?[1-9][0-9]*$/;
          if (!Rep.test(num)) {
            this.$notify({
              title: '警告',
              message: '输入应为整数',
              type: 'warning',
            });
            return;
          }
          if (Rep.test(num)) {
            if (Number(this.tableList[i].planNum) + Number(num) < 0) {
              this.$notify({
                title: '警告',
                message: '第' + (Number(i) + 1) + '行调整后需要大于等于0',
                type: 'warning',
              });
              return false;
            }
          }
        }
      }
      let is = false;
      //获取校验信息
      this.exportLoading = true;
      let arr = this.checkTargetNum();
      const res2 = await queryTargetType({ planYearAndMonth: this.rowData.planYearAndMonth });
      let checkTargetType = res2.resultCode === 200 ? res2.data : null;
      //开始检验
      for (let i in arr) {
        //校验数量
        if (arr[i].targetType === 24031002) {
          for (let b in checkTargetType) {
            if (checkTargetType[b].productCode === arr[i].productCode) {
              //拿到初始物料数量
              let before = 0;
              for (let m in this.wuliaoList) {
                if (arr[i].productCode === this.wuliaoList[m].productCode) {
                  before = Number(this.wuliaoList[m].beforeNum);
                }
              }
              if (Number(checkTargetType[b].planNum) + (Number(arr[i].subtotal) - before) > Number(checkTargetType[b].targetNum)) {
                this.$notify.warning({ title: '提示信息', message: '物料编码{' + checkTargetType[b].productCode + '}配额提报数量大于月度指标配额数量' });
                is = true;
                break;
              }
            }
          }
          if (is) break;
        }
      }
      //紧急度是各车系紧急数量不超过比例
      let arrSeries = this.getUrgencyByseries(arr);
      for (let i in arrSeries) {
        if (Math.floor(Number(arrSeries[i].subtotal) * this.urgencyRate) < Number(arrSeries[i].emergency)) {
          is = true;
          this.$notify.warning({ title: '提示信息', message: '车系{' + arrSeries[i].seriesName + '}紧急提报数不能超过比率' + this.urgencyRate * 100 + '%' });
          break;
        }
      }
      if (is) {
        this.exportLoading = false;
        return false;
      }
      //调整校验
      if (this.rowData.planStatus !== 24041001) {
        let nowAllNum = 0;
        for (let i in arrSeries) {
          nowAllNum += Number(arrSeries[i].general) + Number(arrSeries[i].urgent);
        }
        console.log(nowAllNum, Math.floor(this.planAllunJinJi * this.adjustRate),this.planAllunJinJi)
        if (nowAllNum > Math.floor(this.planAllunJinJi * this.adjustRate) + this.planAllunJinJi || nowAllNum < this.planAllunJinJi - Math.floor(this.planAllunJinJi * this.adjustRate)) {
          this.$notify({
            title: '警告',
            message: '总调整数量比率不能超过' + this.adjustRate * 100 + '%',
            type: 'warning',
          });
          this.exportLoading = false;
          return false;
        }
      }

      //更新表单
      this.rowData.details = this.tableList;
      if (this.rowData.planStatus == 24041002 || this.rowData.planStatus == 24041003) {
        this.rowData.planStatus = 24041003;
      }

      let res = await updateReport(this.rowData);
      if (res.resultCode === 200) {
        this.$notify({
          title: '成功',
          message: '保存成功',
          type: 'success',
        });
        this.exportLoading = false;
        this.$emit('close', this.tableList);
      }
    },
    getUrgencyByseries(valueList) {
      let a = valueList;
      a.forEach((e) => {
        e.iswkc2 = 1;
      });
      if (a.length > 1) {
        for (let i = 0; i < a.length; i++) {
          if (a[i].iswkc2 === 0) {
            continue;
          }
          for (let j = i + 1; j < a.length; j++) {
            if (a[j].iswkc2 === 0) {
              continue;
            }
            if (a[i].seriesId === a[j].seriesId) {
              a[i].general += a[j].general;
              a[i].urgent += a[j].urgent;
              a[i].emergency += a[j].emergency;
              a[i].subtotal += a[j].subtotal;
              a[j].iswkc2 = 0;
            }
          }
        }
      }
      let arr = [];
      a.forEach((e) => {
        if (e.iswkc2 === 1) {
          arr.push(e);
        }
      });
      return arr;
    },
    checkTargetNum() {
      let a = this.tableList;
      a.forEach((e) => {
        e.general = 0;
        e.urgent = 0;
        e.emergency = 0;
        e.iswkc = 1;
        if (e.urgency === 21011001) {
          //一般
          if (e.adjustNum !== null && e.adjustNum !== '') {
            e.general += Number(e.planNum) + Number(e.adjustNum);
          } else {
            e.general += Number(e.planNum);
          }
        }
        if (e.urgency === 21011002) {
          //急
          if (e.adjustNum != null && e.adjustNum !== '') {
            e.urgent += Number(e.planNum) + Number(e.adjustNum);
          } else {
            e.urgent += Number(e.planNum);
          }
          // e.urgent += Number(e.planNum);
        }
        if (e.urgency === 21011003) {
          // 紧急
          if (e.adjustNum != null && e.adjustNum !== '') {
            e.emergency += Number(e.planNum) + Number(e.adjustNum);
          } else {
            e.emergency += Number(e.planNum);
          }
          // e.emergency += Number(e.planNum);
        }
        e.subtotal = e.urgent + e.emergency + e.general;
      });
      if (a.length > 1) {
        for (let i = 0; i < a.length; i++) {
          if (a[i].iswkc === 0) {
            continue;
          }
          for (let j = i + 1; j < a.length; j++) {
            if (a[j].iswkc === 0) {
              continue;
            }
            if (a[i].productCode === a[j].productCode) {
              a[i].general += a[j].general;
              a[i].urgent += a[j].urgent;
              a[i].emergency += a[j].emergency;
              a[i].subtotal += a[j].subtotal;
              a[j].iswkc = 0;
            }
          }
        }
      }
      let arr = [];
      a.forEach((e) => {
        if (e.iswkc === 1) {
          arr.push(e);
        }
      });
      return arr;
    },
    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '计划信息',
        },
        {
          type: 'INPUT',
          label: '计划编号',
          fieldName: 'plan1No',
          placeholder: '请输入',
          disabled: true,
        },
        {
          type: 'DATE',
          label: '计划年月',
          fieldName: 'planYearAndMonth',
          disabled: true,
          placeholder: '请输入',
          dateType: 'month',
        },
        {
          type: 'SELECT',
          label: '计划状态',
          fieldName: 'planStatus',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('2404'),
          // initialValue: 61041001
        },
        {
          type: 'SELECT',
          label: '计划类型',
          fieldName: 'plan1Type',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('2405'),
        },
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'ownerCode',
          placeholder: '请输入',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: '请输入',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '创建人',
          fieldName: 'createdBy',
          placeholder: '请输入',
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '创建时间',
          fieldName: 'createdAt',
          placeholder: '请输入',
          disabled: true,
        },
      ];
    },
    createdFrom1() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '拆分信息',
        },
        {
          type: 'INPUT_NUMBER',
          label: '拆分数量',
          fieldName: 'planNum',
          placeholder: '请输入数字',
          rules: [{ required: true, message: '请输入', trigger: 'change' }],
        },

        // {
        //   type: 'SELECT',
        //   label: '紧急度',
        //   fieldName: 'urgency',
        //   placeholder: '请选择',
        //   rules: [{ required: true, message: '请选择', trigger: 'change' }],
        //   itemList: this.createDictList('2101'),
        // },
      ];
    },
    createdTable() {
      return [
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 120,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <multiuse-button size="mini" type="text" onClick={() => this.editHandle(props.row, 1)} disabled={this.rowData.planStatus !== 24041001}>
                  删除
                </multiuse-button>
                <el-divider direction="vertical" />
                <multiuse-button size="mini" type="text" onClick={() => this.editHandle(props.row, 2)} disabled={this.rowData.planStatus === 24041001}>
                  拆分
                </multiuse-button>
              </div>
            );
          },
        },
        {
          title: '序号',
          dataIndex: 'index',
          width: 50,
          sorter: true,
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },
        {
          title: '物料编码',
          dataIndex: 'productCode',
          width: 200,
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '物料描述',
          dataIndex: 'productName',
          align: 'center',
          width: 400,
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '指标类别',
          dataIndex: 'targetType',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (props) => {
            //编码转汉字
            return <span>{this.createDictText(props.row.targetType, '2403')}</span>;
          },
        },
        {
          title: '提报数量',
          type: 'n',
          dataIndex: 'planNum',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'number',
          width: 100,
          editRequired: true,
          editPattern: /^[1-9]\d*$/,
          summation: true,
          defaultEditable: true,
          rules: [{ required: true, message: '请填写正整数', trigger: 'blur' }],
          disabled: this.rowData.planStatus !== 24041001,
          align: 'center',
        },
        {
          title: '调整数量',
          dataIndex: 'adjustNum',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          editType: 'number',
          width: 100,
          editPattern: /^(-)?[1-9][0-9]*$/,
          summation: true,
          defaultEditable: true,
          hidden: this.rowData.planStatus == 24041001,
          onInput: (index, data) => {
            this.changeNum(index, data);
          },
        },
        {
          title: '紧急度',
          dataIndex: 'urgency',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
          rules: [{ required: true, message: '请填写', trigger: 'blur' }],
          render: (p) => {
            return (
              <el-select
                size="mini"
                disabled={this.rowData.planStatus !== 24041001}
                v-model={p.row.urgency}
                placeholder="请选择"
                onChange={(value) => {
                  p.row.urgency = value;
                }}
              >
                {this.createDictList('2101').map((item) => (
                  <el-option key={item.value} label={item.text} value={item.value} />
                ))}
              </el-select>
            );
          },
        },
        {
          title: '车辆用途',
          dataIndex: 'vehicleUser',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
          rules: [{ required: true, message: '请填写', trigger: 'blur' }],
          render: (p) => {
            return (
              <el-select
                size="mini"
                v-model={p.row.vehicleUser}
                placeholder="请选择"
                onChange={(value) => {
                  p.row.vehicleUser = value;
                }}
              >
                {this.createDictList('2406')
                  .slice(0, 2)
                  .map((item) => (
                    <el-option key={item.value} label={item.text} value={item.value} />
                  ))}
              </el-select>
            );
          },
        },
        {
          title: '资金类型',
          dataIndex: 'accountId',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
          rules: [{ required: true, message: '请填写', trigger: 'blur' }],
          render: (p) => {
            return (
              <el-select
                size="mini"
                v-model={p.row.accountId}
                placeholder="请选择"
                onChange={(value) => {
                  p.row.accountId = value;
                }}
              >
                {p.row.accountTypes.map((item) => (
                  <el-option key={item.accountId} label={item.accountTypeName} value={item.accountId} />
                ))}
              </el-select>
            );
          },
        },
        {
          title: '收车地址',
          dataIndex: 'addressId',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true,
          rules: [{ required: true, message: '请填写', trigger: 'blur' }],
          render: (p) => {
            return (
              <el-select
                size="mini"
                v-model={p.row.addressId}
                placeholder="请选择"
                onChange={(value) => {
                  p.row.addressId = value;
                  for (let x of p.row.addressDTOS) {
                    if (x.addressId == value) {
                      p.row.cityName = x.cityName;
                      p.row.linkMan = x.linkMan;
                      p.row.linkPhone = x.linkPhone;
                      p.row.address = x.address;
                      break;
                    }
                  }
                }}
              >
                {p.row.addressDTOS.map((item) => (
                  <el-option key={item.addressId} label={item.address} value={item.addressId} />
                ))}
              </el-select>
            );
          },
        },
        {
          title: '城市',
          dataIndex: 'cityName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '联系人',
          dataIndex: 'linkMan',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '联系电话',
          dataIndex: 'linkPhone',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '市场指导价',
          dataIndex: 'oemDirectivePrice',
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2,
        },
        {
          title: '车系名称',
          dataIndex: 'seriesName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '车型名称',
          dataIndex: 'modelName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '配置名称',
          dataIndex: 'configName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '选装名称',
          dataIndex: 'optionName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '内饰',
          dataIndex: 'trimColorName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '外饰',
          dataIndex: 'colorName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
      ];
    },

    createdTable1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: (props) => {
            return <span>{props.row.index + 1}</span>;
          },
        },

        {
          title: '物料编码',
          dataIndex: 'productCode',
          width: 200,
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '物料描述',
          dataIndex: 'productName',
          align: 'center',
          width: 400,
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '物料汇总数量',
          dataIndex: 'productTotalNum',
          sorter: true,
          filter: true,
          align: 'center',
          width: 400,
          filterType: 'input',
          children: [
            {
              title: '急',
              type: 'number',
              dataIndex: 'urgent',
              filterType: 'input',
              align: 'center',
              summation: true,
            },
            {
              title: '一般',
              type: 'number',
              dataIndex: 'general',
              filterType: 'input',
              align: 'center',
              summation: true,
            },
            {
              title: '紧急',
              type: 'number',
              dataIndex: 'emergency',
              filterType: 'input',
              align: 'center',
              summation: true,
            },
            {
              title: '小计',
              type: 'number',
              dataIndex: 'subtotal',
              filterType: 'input',
              align: 'center',
              summation: true,
            },
          ],
        },

        {
          title: '车系',
          dataIndex: 'seriesName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '车型名称',
          dataIndex: 'modelName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '配置',
          dataIndex: 'configName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '选装',
          dataIndex: 'optionName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '内饰',
          dataIndex: 'trimColorName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '外饰',
          dataIndex: 'colorName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
      ];
    },
  },
};
</script>
<style lang="less" scoped>
.el-tabs {
  /deep/ .el-tabs__header {
    margin: 0;
  }
  /deep/ .el-tabs__nav-wrap {
    background-color: #ffffff;
    padding-left: 24px;
    .el-tabs__item {
      // height: 32px;
      // line-height: 32px;
      height: 42px;
      line-height: 42px;
      font-size: 16px;
    }
    &.is-top::after {
      height: 1px;
    }
    &.is-left::after {
      width: 1px;
    }
  }
  /deep/ .el-tabs__content {
    position: static !important;
    background: #fff;
  }
}
</style>
